from Tkinter import *
from ttk import *
import threading

class Thread(threading.Thread):
    def __init__(self, command, call_back):
        self._command = command
        self._call_back = call_back
        super(Thread, self).__init__()
       
    def run(self):
        print "Thread Starting"
        self._command()
        print "Thread finished"
        self._call_back()

def progtest(): ## This would be the sync operation
    from time import sleep
#    progBar.start()
    for i in xrange(1, 20):
        sleep(0.4)
        print i
#    progBar.stop()
   
def callback():
    progBar.stop()
    ptest.configure(state= NORMAL)
   
def on_button():
    progBar.start()
    ptest.configure(state= DISABLED)
    thd= Thread(progtest, callback)
    thd.start()
   
   
root = Tk()
Style().configure(style='winnative')
root.title('Directory Syncer')

#ptest = Button(text= 'test', command=progtest)
ptest = Button(text= 'test', command=on_button)
ptest.grid(columns=1, row=7)
progBar = Progressbar(root, orient=HORIZONTAL, length=200, mode='indeterminate')
progBar.grid(columns=1, row=6, padx=10, pady=10)

root.mainloop()
